package com.core.config.transaction;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.system.dao.TransactionLogMapper;
import com.pojo.entity.TransactionLogEntity;
import com.utility.constant.Constant;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author: hw
 * @date: 2021/3/10 16:37
 */
public class TransactionCallBackImpl {

    @Autowired private TransactionLogMapper transactionLogMapper;

    /**
     *  根据事务Id查询 事务业务是否已完成
     * @param transactionId 事务id
     * @return false事务日志未生成，true日志已生成
    */
    public boolean getTransactionCallBack(String transactionId){
        QueryWrapper<TransactionLogEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("transaction_id",transactionId);
        queryWrapper.eq("is_delete", Constant.ZERO);
        List<TransactionLogEntity> transactionLogEntities = transactionLogMapper.selectList(queryWrapper);
        if (transactionLogEntities.isEmpty()){
            return false;
        }
        return true;
    }
}
